<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.jiabonet.DB.staticBean"%>
<%
String path = request.getContextPath();
String Admin = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+staticBean.getAdminDir();
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>添加类型基本信息</title>
<link href="<%=path%>/Public/css/AdminCss.css" rel="stylesheet" type="text/css" />
<script src="<%=path%>/Public/js/jquery.min.js" type="text/javascript"></script>
<script src="<%=path%>/Public/js/jquery.timers.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$("#tables tr").hover(
	  function () {
		$(this).css("background","#d5f4fe");
	  },
	  function () {
		$(this).css("background","#fff");
	  }
	);

	var send = $("input[name='send']");
	var TypePid = $("input[name='Parents']");
	var Path = $("input[name='Path']");
	var TypeName = $("input[name='TypeName']");
	var Content = $("#Content");
	$('#Parent').change(function(){
		var Typeids = $(this).val();
		Path.attr('value',Typeids);
		var List = Typeids.split(',');
		var Typds = List.length - 2;
		TypePid.attr('value',List[Typds]);
	});

	TypeName.blur(function (){
		if(TypeName.val().length >= 2){
			$.ajax({
				   type: "POST",
				   url: "<%=path%>/ShopType!ShopType_TypeIs.action?T="+Math.random(),
				   data: "shopType.Type="+TypeName.val(),
				   success: function(msg){
						 if(msg.isOK==1){
							$("#IsTypeName").show();
						 	$("#IsTypeName1").html(msg.returnInfo).css("color","#69D172");
						 }else{
							$("#IsTypeName").show();
							$("#IsTypeName1").html(msg.returnInfo).css("color","red");
							TypeName.focus();
							return false;
						 }
				   }
			});	
		}else{
			$("#IsTypeName").show();
			$("#IsTypeName1").html("<font color='red'>类型名称格式错误！</font>");
			TypeName.focus();
			return false;
		}
	
	});
	
	send.click(function(){
		if(TypeName.val().length > 24 || TypeName.val().length < 2){
			$("#IsTypeName").show();
			$("#IsTypeName1").html("<font color='red'>类型名称格式错误！</font>");
			$("#IsTypeName1").oneTime(10000, function() {
				$(this).hide();
	        });
	        return false;
		}else{
			$("#IsTypeName").hide();
		}		
		var state = $("input:checked").val();	
		if(state=="on"){ state=1; }else{ state=0; }
		var datas = "shopType.Type="+TypeName.val()+"&shopType.Path="+Path.val()+"&shopType.Parent="+TypePid.val()+"&shopType.Content="+Content.val()+"&shopType.State="+state;
		//alert(datas);
		//return false;
		$.ajax({
			   type: "POST",
			   url: "<%=path%>/ShopType!ShopType_ShopTypeAdd.action?T="+Math.random(),
			   data: datas,
			   success: function(msg){
				   if(msg.isOK==1){
						$("#IsSend").show();
						$("#IsSend1").html(msg.returnInfo).css("color","#69D172");
					}else{
						$("#IsSend").show();
						$("#IsSend1").html(msg.returnInfo).css("color","red");
					}				   
				   TypeName.val("").focus();
			   }
		});
	});

	
});

function trim(str){ //删除左右两端的空格
	　　return str.replace(/(^\s*)|(\s*$)/g, "");
}
//判断输入是否是一个整数  
function isint(str)  
{  
    var result=str.match(/^(-|\+)?\d+$/);  
    if(result==null) return false;  
    return true;  
} 
</script>


</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td>
			<table width="100%" border="0" cellspacing="0"
				cellpadding="0">
				<tr>
					<td width="6%" height="24" valign="center">
						<div align="center">
							<img src="<%=Admin %>/images/tb.gif" width="14" height="14" />
						</div>
					</td>
					<td width="94%" height="24" valign="center">
						<span class="STYLE1"> <strong>添加类型基本信息</strong>
						</span>
					</td>
				</tr>
			</table>
		</td>
            <td><div align="right"><span class="STYLE1">
              &nbsp;&nbsp;<img src="<%=Admin %>/images/edit.gif" width="10" height="10" /> 当前用户：<%=session.getAttribute("Username") %>   &nbsp;</span><span class="STYLE1"> &nbsp;</span></div></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
	<table width="100%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#a8c7ce" id="tables">
		
		<tr height="30">
			<td width="14%" bgcolor="d3eaef" class="STYLE6">
				<div align="center">
					<span class="STYLE10">上级名称：</span>
				</div>
			</td>
			<td width="34%" bgcolor="d3eaef" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					 <select name="Parent" id="Parent" style="width:200px">
						<option value='0,' selected>顶级类型</option>
						<s:iterator value="List" id="content">
							<option value='<s:property value="#content.Path" /><s:property value="#content.Id" />,' <s:if test="#content.Id==shopType.Id">selected</s:if>><s:property value="#content.Type" /> <s:property value="#content.Id" /></option>
						</s:iterator>
					 </select>
					 <br/>
					 <input type="hidden" value="<s:property value="shopType.Path" /><s:property value="shopType.Id" />," size="22" name="Path">
					 <input type="hidden" value="<s:property value="shopType.Parent" />" size="22" name="Parents">
					</span>
				</div>
			</td>
			<td width="52%" bgcolor="d3eaef" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（选择上级类型）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsTypePid" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsTypePid1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">类型名称：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> <input
							type="text" value="" maxlength="24" size="24"
							name="TypeName"> </span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（不能为空，大于2位或少于20位）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsTypeName" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsTypeName1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">类型状态：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> 
					<input type="checkbox" name="State" checked="checked">
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（勾选为开启，否则为关闭）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsState" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsState1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="50">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">使用说明：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> 
					<textarea rows="5" cols="30" name="Content" id="Content"></textarea>
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（可以为空）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsContent" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsContent1">
					</span>
				</div>
			</td>
		</tr>
		
		
		<tr bgcolor="#ffffff" height="30">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10"> <input type="submit" value="确定"
							name="send">&nbsp;&nbsp; <input type="button"
							value="关闭" onClick="window.close();" name="send"> </span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsSend" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsSend1">
					</span>
				</div>
			</td>
		</tr>
	</table>
	</td>
  </tr>
</table>
</body>
</html>